```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>IP与TCP协议解析 | 网络协议深度剖析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 3.5em;
            line-height: 0.8em;
            padding-right: 0.1em;
            margin-top: 0.15em;
            color: #6e8efb;
            font-weight: bold;
        }
        .section-divider {
            border-top: 1px solid #e2e8f0;
            position: relative;
            margin: 3rem 0;
        }
        .section-divider::after {
            content: "";
            position: absolute;
            top: -5px;
            left: 50%;
            transform: translateX(-50%);
            width: 40px;
            height: 10px;
            background: #6e8efb;
            border-radius: 5px;
        }
        .feature-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 48px;
            height: 48px;
            border-radius: 12px;
            margin-bottom: 1rem;
            background: linear-gradient(135deg, #a777e3 0%, #6e8efb 100%);
            color: white;
            font-size: 1.5rem;
        }
        .scroll-indicator {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            animation: bounce 2s infinite;
        }
        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% {transform: translateY(0) translateX(-50%);}
            40% {transform: translateY(-20px) translateX(-50%);}
            60% {transform: translateY(-10px) translateX(-50%);}
        }
        .tcp-ip-diagram {
            background-color: #f8fafc;
            border-radius: 12px;
            padding: 2rem;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 relative overflow-hidden">
        <div class="container mx-auto px-6 relative z-10">
            <div class="max-w-3xl mx-auto text-center">
                <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">揭秘网络通信的核心协议</h1>
                <p class="text-xl md:text-2xl opacity-90 mb-8">IP与TCP协议的分层架构与协作机制解析</p>
                <div class="inline-flex items-center space-x-2 bg-white bg-opacity-20 rounded-full px-6 py-2">
                    <i class="fas fa-network-wired"></i>
                    <span>网络协议栈</span>
                </div>
            </div>
        </div>
        <div class="scroll-indicator">
            <i class="fas fa-chevron-down text-white text-2xl"></i>
        </div>
    </div>

    <!-- Introduction Section -->
    <section class="container mx-auto px-6 py-16 max-w-5xl">
        <div class="drop-cap text-lg md:text-xl text-gray-700 leading-relaxed">
            IP 和 TCP 是互联网协议栈中两个不同层次的协议。IP 负责网络层的基本寻址和路由功能，而 TCP 在其上提供了可靠的数据传输服务。IP 层不能解决数据传输的可靠性、顺序、流量和拥塞控制等问题，因此需要 TCP 层来实现这些功能，以保证数据能够正确、可靠地传输到目标设备。这种分层设计允许协议栈中的每一层专注于特定的任务，从而简化了网络通信的复杂性。
        </div>
    </section>

    <!-- Diagram Section -->
    <section class="container mx-auto px-6 py-12 max-w-5xl">
        <div class="tcp-ip-diagram">
            <div class="mermaid">
                flowchart TD
                    A[应用层\nHTTP, FTP, SMTP] -->|数据| B[TCP层]
                    B -->|数据段| C[IP层]
                    C -->|数据包| D[网络接口层]
                    D -->|帧| E[物理网络]
                    E --> D
                    D --> C
                    C --> B
                    B --> A
                    
                    subgraph 传输层
                    B[TCP\n连接管理\n可靠性保证\n流量控制\n拥塞控制]
                    end
                    
                    subgraph 网络层
                    C[IP\n寻址\n路由\n分片重组]
                    end
            </div>
        </div>
    </section>

    <!-- IP Section -->
    <section class="container mx-auto px-6 py-12 max-w-5xl">
        <div class="text-center mb-16">
            <span class="inline-block px-4 py-1 bg-blue-100 text-blue-600 rounded-full text-sm font-medium mb-3">网络层</span>
            <h2 class="text-3xl md:text-4xl font-bold text-gray-800 font-serif">IP 协议的核心职责</h2>
        </div>
        
        <div class="grid md:grid-cols-2 gap-8">
            <div class="bg-white p-8 rounded-xl shadow-md card-hover">
                <div class="feature-icon">
                    <i class="fas fa-map-marked-alt"></i>
                </div>
                <h3 class="text-xl font-bold mb-3">寻址与路由</h3>
                <p class="text-gray-600">为每台设备分配唯一的IP地址，并确定数据包从源设备到目标设备的最佳路径。IP协议通过路由表决定数据包的下一跳，形成一个分布式的路由系统。</p>
            </div>
            
            <div class="bg-white p-8 rounded-xl shadow-md card-hover">
                <div class="feature-icon">
                    <i class="fas fa-puzzle-piece"></i>
                </div>
                <h3 class="text-xl font-bold mb-3">分片与重组</h3>
                <p class="text-gray-600">当数据包超过网络的最大传输单元(MTU)时，IP协议将其分割成多个片段，并在接收端进行重组。这一过程对上层协议透明，确保了大数据包在不同MTU的网络间传输。</p>
            </div>
        </div>
        
        <div class="bg-white p-8 rounded-xl shadow-md mt-8">
            <h3 class="text-xl font-bold mb-4 flex items-center">
                <i class="fas fa-info-circle text-blue-500 mr-2"></i>
                IP协议的关键特点
            </h3>
            <div class="grid sm:grid-cols-2 gap-4">
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-5 w-5 text-blue-500 mt-1 mr-2">
                        <i class="fas fa-unlink"></i>
                    </div>
                    <div>
                        <h4 class="font-medium text-gray-800">无连接</h4>
                        <p class="text-gray-600 text-sm">IP不建立连接，每个数据包独立处理，不保证到达顺序。</p>
                    </div>
                </div>
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-5 w-5 text-blue-500 mt-1 mr-2">
                        <i class="fas fa-exclamation-triangle"></i>
                    </div>
                    <div>
                        <h4 class="font-medium text-gray-800">不可靠</h4>
                        <p class="text-gray-600 text-sm">仅负责发送和路由，不保证数据包的到达或正确性。</p>
                    </div>
                </div>
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-5 w-5 text-blue-500 mt-1 mr-2">
                        <i class="fas fa-random"></i>
                    </div>
                    <div>
                        <h4 class="font-medium text-gray-800">尽力而为</h4>
                        <p class="text-gray-600 text-sm">尽最大努力交付数据包，但不做任何质量保证。</p>
                    </div>
                </div>
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-5 w-5 text-blue-500 mt-1 mr-2">
                        <i class="fas fa-globe"></i>
                    </div>
                    <div>
                        <h4 class="font-medium text-gray-800">全球可达</h4>
                        <p class="text-gray-600 text-sm">通过分层编址实现全球范围内的设备寻址。</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Section Divider -->
    <div class="container mx-auto px-6 max-w-5xl">
        <div class="section-divider"></div>
    </div>

    <!-- TCP Section -->
    <section class="container mx-auto px-6 py-12 max-w-5xl">
        <div class="text-center mb-16">
            <span class="inline-block px-4 py-1 bg-purple-100 text-purple-600 rounded-full text-sm font-medium mb-3">传输层</span>
            <h2 class="text-3xl md:text-4xl font-bold text-gray-800 font-serif">TCP 协议的可靠性保障</h2>
        </div>
        
        <div class="grid md:grid-cols-3 gap-6 mb-12">
            <div class="bg-white p-6 rounded-xl shadow-sm border-l-4 border-purple-500 card-hover">
                <h3 class="text-lg font-bold mb-2 flex items-center">
                    <i class="fas fa-handshake text-purple-500 mr-2"></i>
                    连接建立
                </h3>
                <p class="text-gray-600 text-sm">通过三次握手(SYN, SYN-ACK, ACK)建立可靠连接，确保双方通信链路已准备好。</p>
            </div>
            <div class="bg-white p-6 rounded-xl shadow-sm border-l-4 border-purple-500 card-hover">
                <h3 class="text-lg font-bold mb-2 flex items-center">
                    <i class="fas fa-check-circle text-purple-500 mr-2"></i>
                    数据完整性
                </h3>
                <p class="text-gray-600 text-sm">通过校验和、确认应答和重传机制保证数据在传输过程中没有错误。</p>
            </div>
            <div class="bg-white p-6 rounded-xl shadow-sm border-l-4 border-purple-500 card-hover">
                <h3 class="text-lg font-bold mb-2 flex items-center">
                    <i class="fas fa-sort-numeric-down text-purple-500 mr-2"></i>
                    顺序控制
                </h3>
                <p class="text-gray-600 text-sm">通过序列号和确认号确保数据包按照正确的顺序到达目标。</p>
            </div>
            <div class="bg-white p-6 rounded-xl shadow-sm border-l-4 border-purple-500 card-hover">
                <h3 class="text-lg font-bold mb-2 flex items-center">
                    <i class="fas fa-tachometer-alt text-purple-500 mr-2"></i>
                    流量控制
                </h3>
                <p class="text-gray-600 text-sm">通过窗口机制调整数据传输速率，防止发送方过快地发送数据。</p>
            </div>
            <div class="bg-white p-6 rounded-xl shadow-sm border-l-4 border-purple-500 card-hover">
                <h3 class="text-lg font-bold mb-2 flex items-center">
                    <i class="fas fa-traffic-light text-purple-500 mr-2"></i>
                    拥塞控制
                </h3>
                <p class="text-gray-600 text-sm">动态调整数据传输速率，防止网络拥堵，包括慢启动、拥塞避免等算法。</p>
            </div>
            <div class="bg-white p-6 rounded-xl shadow-sm border-l-4 border-purple-500 card-hover">
                <h3 class="text-lg font-bold mb-2 flex items-center">
                    <i class="fas fa-exchange-alt text-purple-500 mr-2"></i>
                    全双工通信
                </h3>
                <p class="text-gray-600 text-sm">允许双方同时发送和接收数据，提高通信效率。</p>
            </div>
        </div>
        
        <div class="bg-purple-50 p-8 rounded-xl">
            <h3 class="text-xl font-bold mb-4 flex items-center">
                <i class="fas fa-star text-purple-500 mr-2"></i>
                TCP协议的关键特点
            </h3>
            <div class="grid gap-6 md:grid-cols-2">
                <div>
                    <div class="flex items-start mb-4">
                        <div class="flex-shrink-0 h-5 w-5 text-purple-500 mt-1 mr-3">
                            <i class="fas fa-plug"></i>
                        </div>
                        <div>
                            <h4 class="font-medium text-gray-800">有连接</h4>
                            <p class="text-gray-600">TCP在数据传输前建立连接，确保双方的通信链路已经准备好。</p>
                        </div>
                    </div>
                    <div class="flex items-start mb-4">
                        <div class="flex-shrink-0 h-5 w-5 text-purple-500 mt-1 mr-3">
                            <i class="fas fa-shield-alt"></i>
                        </div>
                        <div>
                            <h4 class="font-medium text-gray-800">可靠</h4>
                            <p class="text-gray-600">提供数据的完整性检查、重传机制等，确保数据按序到达并且无误。</p>
                        </div>
                    </div>
                </div>
                <div class="mermaid">
                    sequenceDiagram
                        participant Client
                        participant Server
                        Client->>Server: SYN (seq=x)
                        Server->>Client: SYN-ACK (seq=y, ack=x+1)
                        Client->>Server: ACK (seq=x+1, ack=y+1)
                        Note over Client,Server: 连接建立完成<br>开始数据传输
                </div>
            </div>
        </div>
    </section>

    <!-- Comparison Section -->
    <section class="container mx-auto px-6 py-16 max-w-5xl">
        <div class="text-center mb-12">
            <h2 class="text-3xl md:text-4xl font-bold text-gray-800 font-serif">IP与TCP的互补关系</h2>
            <p class="text-gray-600 max-w-2xl mx-auto mt-4">分层设计如何实现高效可靠的网络通信</p>
        </div>
        
        <div class="bg-white rounded-xl shadow-md overflow-hidden">
            <div class="grid md:grid-cols-2 divide-y md:divide-y-0 md:divide-x divide-gray-200">
                <div class="p-8">
                    <h3 class="text-2xl font-bold mb-6 text-blue-600 flex items-center">
                        <i class="fas fa-layer-group mr-3"></i>
                        IP层的局限性
                    </h3>
                    <ul class="space-y-4">
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-blue-500 mt-1 mr-3">
                                <i class="fas fa-times-circle"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800">无法保证可靠性</h4>
                                <p class="text-gray-600 text-sm">只负责发送数据包，无法保证数据包是否成功到达、是否出现错误或丢失。</p>
                            </div>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-blue-500 mt-1 mr-3">
                                <i class="fas fa-random"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800">无法保证顺序</h4>
                                <p class="text-gray-600 text-sm">数据包可能经过不同路径到达，导致顺序混乱，IP本身不处理这些问题。</p>
                            </div>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-blue-500 mt-1 mr-3">
                                <i class="fas fa-tachometer-alt"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800">无流量控制</h4>
                                <p class="text-gray-600 text-sm">不关注发送速率和网络状态，无法根据接收方能力调整发送速度。</p>
                            </div>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-blue-500 mt-1 mr-3">
                                <i class="fas fa-project-diagram"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800">无连接管理</h4>
                                <p class="text-gray-600 text-sm">没有建立和管理连接的机制，无法实现基于连接的可靠通信。</p>
                            </div>
                        </li>
                    </ul>
                </div>
                
                <div class="p-8">
                    <h3 class="text-2xl font-bold mb-6 text-purple-600 flex items-center">
                        <i class="fas fa-puzzle-piece mr-3"></i>
                        TCP如何弥补不足
                    </h3>
                    <ul class="space-y-4">
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-purple-500 mt-1 mr-3">
                                <i class="fas fa-check-double"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800">可靠传输机制</h4>
                                <p class="text-gray-600 text-sm">通过确认应答和重传确保每个数据包都成功到达目标。</p>
                            </div>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-purple-500 mt-1 mr-3">
                                <i class="fas fa-sort-amount-up"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800">序列号控制</h4>
                                <p class="text-gray-600 text-sm">通过序列号确保数据包按顺序到达，重新排序乱序数据。</p>
                            </div>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-purple-500 mt-1 mr-3">
                                <i class="fas fa-sliders-h"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800">动态窗口调整</h4>
                                <p class="text-gray-600 text-sm">使用窗口机制匹配接收方处理能力，避免数据溢出。</p>
                            </div>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-purple-500 mt-1 mr-3">
                                <i class="fas fa-network-wired"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800">智能拥塞控制</h4>
                                <p class="text-gray-600 text-sm">实施慢启动、拥塞避免等算法防止网络拥堵，动态调整速率。</p>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        
        <div class="mt-12 bg-blue-50 p-8 rounded-xl">
            <h3 class="text-xl font-bold mb-4 text-blue-700">分层设计的优势</h3>
            <p class="text-gray-700 mb-6">TCP/IP协议栈的分层设计体现了"关注点分离"的工程哲学，每一层专注于解决特定问题：</p>
            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-lg shadow-sm">
                    <div class="text-blue-500 text-2xl mb-3">
                        <i class="fas fa-cubes"></i>
                    </div>
                    <h4 class="font-bold text-gray-800 mb-2">模块化设计</h4>
                    <p class="text-gray-600 text-sm">各层独立发展，互不干扰，提高协议的灵活性和可扩展性。</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-sm">
                    <div class="text-blue-500 text-2xl mb-3">
                        <i class="fas fa-sitemap"></i>
                    </div>
                    <h4 class="font-bold text-gray-800 mb-2">抽象封装</h4>
                    <p class="text-gray-600 text-sm">上层无需了解下层实现细节，只需通过定义良好的接口交互。</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-sm">
                    <div class="text-blue-500 text-2xl mb-3">
                        <i class="fas fa-users-cog"></i>
                    </div>
                    <h4 class="font-bold text-gray-800 mb-2">协同工作</h4>
                    <p class="text-gray-600 text-sm">IP提供基础通信能力，TCP增强可靠性，共同构建完整的通信解决方案。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <h3 class="text-xl font-medium text-white mb-2">技术小馆</h3>
                <p class="mb-6">探索技术奥秘，分享知识精华</p>
                <a href="http://www.yuque.com/jtostring" class="inline-block px-4 py-2 bg-gray-800 hover:bg-gray-700 rounded-md transition-colors duration-200">
                    <i class="fas fa-external-link-alt mr-2"></i>
                    访问技术小馆
                </a>
                <div class="mt-8 pt-8 border-t border-gray-800 text-sm text-gray-500">
                    &copy; 2023 技术小馆. 保留所有权利.
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            sequence: {
                diagramMarginX: 50,
                diagramMarginY: 10,
                boxTextMargin: 5,
                noteMargin: 10,
                messageMargin: 35,
                mirrorActors: true
            }
        });
        
        // 简单的滚动动画
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```